<template>
  <div class="register">
      <div class="title">用户注册</div>
      <p class="input"><input type="text" placeholder="请输入账号名" v-model="account" ref="account"></p>
      <p class="input"><input type="text" placeholder="请输入您的密码" v-model="password" ref="password"></p>
      <p class="xieyi">
          <input type="checkbox" checked>
          我已阅读并同意
          <span>《美团网用户协议》</span>
      </p>
      <p><button @click="goMeituanAction">注册</button></p>    
      <p class="kefu">© 猫眼电影 客服电话：
          <span class="phone1">400-670-5335</span>
      </p>
  </div>
</template>

<script>
export default {
    data(){
        return{
            account:'',
            password:'',
        }
    },
    methods:{
        goMeituanAction(){
            var reg1=/^(1|\+861)[3-8]{1}\d{9}$/;
            if(!reg1.test(this.account)){
                alert('请输入正确的手机号！');
                return;
            }
            if(this.password.length<6||this.password.lenght>12){
                alert('密码要在6-12位之间！');
                return;
            }
            // if(JSON.parse(localStorage.getItem('register'))){
            //     localStorage.setItem('register',JSON.stringify(JSON.parse(localStorage.getItem('register')).push({
            //         account:this.account,
            //         password:this.password,
            //     })))
                
            // }
            // else{
                localStorage.setItem('register',JSON.stringify({
                    account:this.account,
                    password:this.password,
                }))
            // }
            
            this.$router.replace('meituan');
        }
    }
}
</script>

<style scoped lang="scss">
.register{
    width:100%;
    position:absolute;
    top:50px;
    background-color: #fff;
}
.title{
    color:#333;
    line-height:40px;
    text-align:center;
    font-size:16px;
    border-bottom:1px solid #ddd;
    margin-bottom:5px;
    font-weight:400;
}
.input{
    width:100%;
    height:50px;
    box-sizing: border-box;
    padding:10px;   
    border-bottom:1px solid #ddd;
    input{
        border:none;
        width:100%;
        height:100%;
        font-size:16px;
        &:focus{
            background-color: #ddd;
            outline:none;
            border-radius: 3px;
        }
    }   
}
.xieyi{
    line-height:40px;
    color:#333;
    font-size:16px;
    input{
        width:24px;
        height:24px;
        margin:8px;
        background-color: #df2d2d;
        // color:#df2d2d;
    }
    span{
        color:#df2d2d;
    }
}
button{
    width:calc(100% - 20px);
    height:40px;
    box-sizing: border-box;
    margin:10px;
    text-align:center;
    color:#fff;
    background-color: #df2d2d;
    border:none;
    border-radius:10px;
    font-size:16px;
}
.kefu{
    width:100%;
    height:40px;
    display:flex;
    justify-content: center;
    align-items: center;
    font-size:14px;
    color:#333;
    .phone1{
        color:#df2d2d;
    }
}
</style>